package application

import (
	"github.com/gin-gonic/gin"
	"ruoyi/domain/entity/common"
	"ruoyi/domain/entity/response"
	"ruoyi/domain/entity/system"
	"ruoyi/domain/repository"
)

type UserApp struct {
	user repository.SysUserRepository
}

var _ UserAppInterface = &UserApp{}

type UserAppInterface interface {
	FindUserByName(loginName string) system.SysUser

	IsAdminById(userId int) bool

	IsAdmin(user *system.SysUser) bool

	IsExistUserByPhoneNumber(phoneNumber string) bool

	IsExistUserByEmail(email string) bool

	FindUserById(id any) system.SysUser

	CheckUserDataScope(userId int, useridP int)

	SelectUserList(params common.SearchTableDataParam, isPage bool) common.TableDataInfo

	SelectUserParamList(params common.SearchTableDataParam, isPage bool) common.TableDataInfo

	GetUserDeptTree() []system.SysDeptDto

	ImportUserData(users []system.SysUserParam, updateSupport string) (string, string)

	SaveUser(user system.SysUserParam) string

	UploadUser(userParam system.SysUserParam)

	EditProfileUserInfo(userId int, param system.UserParam) response.Response

	DeleteUser(userId []int) response.Response

	DeleteUserById(userId []int) response.Response

	ResetPwd(param system.SysUserParam) response.Response

	FindUser(param system.LoginParam, context *gin.Context)

	IsExistUser(loginName string) bool

	UpdatePassWord(newPassWord string, user system.SysUser)

	UpdateAvatar(Filename string, user system.SysUser)

	ChangeUserStatus(param system.SysUserParam) response.Response
}

func (u *UserApp) FindUser(param system.LoginParam, context *gin.Context) {
	u.user.FindUser(param, context)
}

func (u *UserApp) IsExistUser(loginName string) bool {
	return u.user.IsExistUser(loginName)
}

func (u *UserApp) FindUserById(id any) system.SysUser {
	return u.user.FindUserById(id)
}

func (u *UserApp) IsAdminById(userId int) bool {
	return u.user.IsAdminById(userId)
}

func (u *UserApp) FindUserByName(loginName string) system.SysUser {
	return u.user.FindUserByName(loginName)
}

func (u *UserApp) IsAdmin(user *system.SysUser) bool {
	return u.user.IsAdmin(user)
}

func (u *UserApp) IsExistUserByPhoneNumber(phoneNumber string) bool {
	return u.user.IsExistUserByPhoneNumber(phoneNumber)
}

func (u *UserApp) IsExistUserByEmail(email string) bool {
	return u.user.IsExistUserByEmail(email)
}

func (u *UserApp) CheckUserDataScope(userId int, useridP int) {
	u.user.CheckUserDataScope(userId, useridP)
}

func (u *UserApp) SelectUserList(params common.SearchTableDataParam, isPage bool) common.TableDataInfo {
	return u.user.SelectUserList(params, isPage)
}

func (u *UserApp) SelectUserParamList(params common.SearchTableDataParam, isPage bool) common.TableDataInfo {
	return u.user.SelectUserParamList(params, isPage)
}

func (u *UserApp) GetUserDeptTree() []system.SysDeptDto {
	return u.user.GetUserDeptTree()
}

func (u *UserApp) ImportUserData(users []system.SysUserParam, updateSupport string) (string, string) {
	return u.user.ImportUserData(users, updateSupport)
}

func (u *UserApp) SaveUser(user system.SysUserParam) string {
	return u.user.SaveUser(user)
}

func (u *UserApp) UploadUser(userParam system.SysUserParam) {
	u.user.UploadUser(userParam)
}

func (u *UserApp) EditProfileUserInfo(userId int, param system.UserParam) response.Response {
	return u.user.EditProfileUserInfo(userId, param)
}

func (u *UserApp) DeleteUser(userId []int) response.Response {
	return u.user.DeleteUser(userId)
}

func (u *UserApp) DeleteUserById(userId []int) response.Response {
	return u.user.DeleteUserById(userId)
}

func (u *UserApp) ResetPwd(param system.SysUserParam) response.Response {
	return u.user.ResetPwd(param)
}

func (u *UserApp) UpdatePassWord(newPassWord string, user system.SysUser) {
	u.user.UpdatePassWord(newPassWord, user)
}

func (u *UserApp) UpdateAvatar(Filename string, user system.SysUser) {
	u.user.UpdateAvatar(Filename, user)
}

func (u *UserApp) ChangeUserStatus(param system.SysUserParam) response.Response {
	return u.user.ChangeUserStatus(param)
}
